﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using Microhard.Framework.Extensions;

namespace Microhard.Framework.MVCHelper.ViewEngine
{
    public class MicrohardViewEngine : WebFormViewEngine
    {
        private string GetAreaName(RouteData routeData)
        {
            object obj2;
            if (routeData.DataTokens.TryGetValue("area", out obj2))
            {
                return (obj2 as string);
            }
            return GetAreaName(routeData);
        }

        public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
        {
            var http = controllerContext.HttpContext;
            if (http.IsSuitableMobile() || http.IsWeixinClientRequest())
            {
                viewName = viewName + ".Mobile";
            }
            return base.FindView(controllerContext, viewName, masterName, useCache);
        }

    }
}
